package org.resort.service.impl;

import org.resort.dao.EmployeeDao;
import org.resort.dao.RolePrivilegeDao;
import org.resort.entity.Employee;
import org.resort.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author 郭文虎
 */
@Service("commonService")
public class CommonServiceImpl implements CommonService {
    @Autowired
    EmployeeDao employeeDao;
    @Autowired
    RolePrivilegeDao rolePrivilegeDao;

    @Override
    public Employee employeeLogin(String account, String password) {
        //获取员工登录信息
        Employee employee = employeeDao.login(account, password);
        //获取员工所对应的权限
        if (employee!=null) {
            employee.getRole().setRolePrivilegeList(rolePrivilegeDao.getRolePrivilegeByRoleId(employee.getRole().getId()));
        }
        return employee;
    }
}
